

<!DOCTYPE html>
<html lang="zh-CN" data-default-color-scheme=auto>



<head>
  <meta charset="UTF-8">
  <link rel="apple-touch-icon" sizes="76x76" href="/img/fluid.png">
  <link rel="icon" href="/img/fluid.png">
  <meta name="viewport" content="width=device-width, initial-scale=1.0, maximum-scale=5.0, shrink-to-fit=no">
  <meta http-equiv="x-ua-compatible" content="ie=edge">
  
  <meta name="theme-color" content="#2f4154">
  <meta name="author" content="深海火锅店">
  <meta name="keywords" content="">
  
    <meta name="description" content="新建SpringBoot项目下文包括使用sts、idea新建SpringBoot项目，并编写登录逻辑以及测试  新建SpringBoot项目   使用Spring Tool Suite 右键新建，选择Spring Starter Project     注意：其实不安装lombok插件也没什么，手动给get、set方法 和 有参、无参的构造方法即可 sts 的lombok插件需要自己安装jar包，">
<meta property="og:type" content="article">
<meta property="og:title" content="新建SpringBoot项目">
<meta property="og:url" content="http://example.com/2022/11/27/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/Java/%E5%AD%A6%E4%B9%A0/%E6%A1%86%E6%9E%B6/SpringBoot/%E6%96%B0%E5%BB%BAspringboot%E9%A1%B9%E7%9B%AE/index.html">
<meta property="og:site_name" content="Hexo">
<meta property="og:description" content="新建SpringBoot项目下文包括使用sts、idea新建SpringBoot项目，并编写登录逻辑以及测试  新建SpringBoot项目   使用Spring Tool Suite 右键新建，选择Spring Starter Project     注意：其实不安装lombok插件也没什么，手动给get、set方法 和 有参、无参的构造方法即可 sts 的lombok插件需要自己安装jar包，">
<meta property="og:locale" content="zh_CN">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201930984.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931798.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931023.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931066.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931675.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931906.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931512.png">
<meta property="og:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931989.png">
<meta property="article:published_time" content="2022-11-27T03:00:00.000Z">
<meta property="article:modified_time" content="2024-02-15T16:04:48.977Z">
<meta property="article:author" content="深海火锅店">
<meta name="twitter:card" content="summary_large_image">
<meta name="twitter:image" content="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201930984.png">
  
  
    <meta name="referrer" content="no-referrer-when-downgrade">
  
  
  <title>新建SpringBoot项目 - Hexo</title>

  <link  rel="stylesheet" href="https://lib.baomitu.com/twitter-bootstrap/4.6.1/css/bootstrap.min.css" />



  <link  rel="stylesheet" href="https://lib.baomitu.com/github-markdown-css/4.0.0/github-markdown.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/hint.css/2.7.0/hint.min.css" />

  <link  rel="stylesheet" href="https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.css" />



<!-- 主题依赖的图标库，不要自行修改 -->
<!-- Do not modify the link that theme dependent icons -->

<link rel="stylesheet" href="//at.alicdn.com/t/font_1749284_hj8rtnfg7um.css">



<link rel="stylesheet" href="//at.alicdn.com/t/font_1736178_lbnruvf0jn.css">


<link  rel="stylesheet" href="/css/main.css" />


  <link id="highlight-css" rel="stylesheet" href="/css/highlight.css" />
  
    <link id="highlight-css-dark" rel="stylesheet" href="/css/highlight-dark.css" />
  




  <script id="fluid-configs">
    var Fluid = window.Fluid || {};
    Fluid.ctx = Object.assign({}, Fluid.ctx)
    var CONFIG = {"hostname":"example.com","root":"/","version":"1.9.3","typing":{"enable":true,"typeSpeed":70,"cursorChar":"_","loop":false,"scope":[]},"anchorjs":{"enable":true,"element":"h1,h2,h3,h4,h5,h6","placement":"left","visible":"hover","icon":""},"progressbar":{"enable":true,"height_px":3,"color":"#29d","options":{"showSpinner":false,"trickleSpeed":100}},"code_language":{"enable":true,"default":"TEXT"},"copy_btn":true,"image_caption":{"enable":true},"image_zoom":{"enable":true,"img_url_replace":["",""]},"toc":{"enable":true,"placement":"right","headingSelector":"h1,h2,h3,h4,h5,h6","collapseDepth":0},"lazyload":{"enable":true,"loading_img":"/img/loading.gif","onlypost":false,"offset_factor":2},"web_analytics":{"enable":false,"follow_dnt":true,"baidu":null,"google":null,"gtag":null,"tencent":{"sid":null,"cid":null},"woyaola":null,"cnzz":null,"leancloud":{"app_id":null,"app_key":null,"server_url":null,"path":"window.location.pathname","ignore_local":false}},"search_path":"/local-search.xml"};

    if (CONFIG.web_analytics.follow_dnt) {
      var dntVal = navigator.doNotTrack || window.doNotTrack || navigator.msDoNotTrack;
      Fluid.ctx.dnt = dntVal && (dntVal.startsWith('1') || dntVal.startsWith('yes') || dntVal.startsWith('on'));
    }
  </script>
  <script  src="/js/utils.js" ></script>
  <script  src="/js/color-schema.js" ></script>
  


  
<meta name="generator" content="Hexo 6.3.0"></head>


<body>
  

  <header>
    

<div class="header-inner" style="height: 70vh;">
  <nav id="navbar" class="navbar fixed-top  navbar-expand-lg navbar-dark scrolling-navbar">
  <div class="container">
    <a class="navbar-brand" href="/">
      <strong>Fluid</strong>
    </a>

    <button id="navbar-toggler-btn" class="navbar-toggler" type="button" data-toggle="collapse"
            data-target="#navbarSupportedContent"
            aria-controls="navbarSupportedContent" aria-expanded="false" aria-label="Toggle navigation">
      <div class="animated-icon"><span></span><span></span><span></span></div>
    </button>

    <!-- Collapsible content -->
    <div class="collapse navbar-collapse" id="navbarSupportedContent">
      <ul class="navbar-nav ml-auto text-center">
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/">
                <i class="iconfont icon-home-fill"></i>
                首页
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/archives/">
                <i class="iconfont icon-archive-fill"></i>
                归档
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/categories/">
                <i class="iconfont icon-category-fill"></i>
                分类
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/tags/">
                <i class="iconfont icon-tags-fill"></i>
                标签
              </a>
            </li>
          
        
          
          
          
          
            <li class="nav-item">
              <a class="nav-link" href="/about/">
                <i class="iconfont icon-user-fill"></i>
                关于
              </a>
            </li>
          
        
        
          <li class="nav-item" id="search-btn">
            <a class="nav-link" target="_self" href="javascript:;" data-toggle="modal" data-target="#modalSearch" aria-label="Search">
              &nbsp;<i class="iconfont icon-search"></i>&nbsp;
            </a>
          </li>
          
        
        
          <li class="nav-item" id="color-toggle-btn">
            <a class="nav-link" target="_self" href="javascript:;" aria-label="Color Toggle">&nbsp;<i
                class="iconfont icon-dark" id="color-toggle-icon"></i>&nbsp;</a>
          </li>
        
      </ul>
    </div>
  </div>
</nav>

  

<div id="banner" class="banner" parallax=true
     style="background: url('/img/background.jpg') no-repeat center center; background-size: cover;">
  <div class="full-bg-img">
    <div class="mask flex-center" style="background-color: rgba(0, 0, 0, 0.3)">
      <div class="banner-text text-center fade-in-up">
        <div class="h2">
          
            <span id="subtitle" data-typed-text="新建SpringBoot项目"></span>
          
        </div>

        
          
  <div class="mt-3">
    
    
      <span class="post-meta">
        <i class="iconfont icon-date-fill" aria-hidden="true"></i>
        <time datetime="2022-11-27 11:00" pubdate>
          2022年11月27日 上午
        </time>
      </span>
    
  </div>

  <div class="mt-1">
    
      <span class="post-meta mr-2">
        <i class="iconfont icon-chart"></i>
        
          8.1k 字
        
      </span>
    

    
      <span class="post-meta mr-2">
        <i class="iconfont icon-clock-fill"></i>
        
        
        
          68 分钟
        
      </span>
    

    
    
  </div>


        
      </div>

      
    </div>
  </div>
</div>

</div>

  </header>

  <main>
    
      

<div class="container-fluid nopadding-x">
  <div class="row nomargin-x">
    <div class="side-col d-none d-lg-block col-lg-2">
      

    </div>

    <div class="col-lg-8 nopadding-x-md">
      <div class="container nopadding-x-md" id="board-ctn">
        <div id="board">
          <article class="post-content mx-auto">
            <!-- SEO header -->
            <h1 style="display: none">新建SpringBoot项目</h1>
            
            
              <div class="markdown-body">
                
                <h3 id="新建SpringBoot项目"><a href="#新建SpringBoot项目" class="headerlink" title="新建SpringBoot项目"></a>新建SpringBoot项目</h3><p>下文包括使用sts、idea新建SpringBoot项目，并编写登录逻辑以及测试</p>
<ol>
<li>新建SpringBoot项目</li>
</ol>
<ul>
<li><p>使用Spring Tool Suite</p>
<p>右键新建，选择Spring Starter Project</p>
<img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201930984.png" srcset="/img/loading.gif" lazyload alt="新建springboot项目1" style="zoom: 67%;" />

<img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931798.png" srcset="/img/loading.gif" lazyload alt="新建springboot项目2" style="zoom:67%;" />

<p>注意：其实不安装lombok插件也没什么，手动给get、set方法 和 有参、无参的构造方法即可</p>
<p>sts 的lombok插件需要自己安装jar包，安装过程上网查找，这里不再多说；idea的插件安装 同</p>
</li>
<li><p>使用IDEA</p>
<img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931023.png" srcset="/img/loading.gif" lazyload alt="新建springboot项目1" style="zoom: 67%;" />

<img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931066.png" srcset="/img/loading.gif" lazyload alt="新建springboot项目2" style="zoom:67%;" />

<img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931675.png" srcset="/img/loading.gif" lazyload alt="新建springboot项目3" style="zoom:67%;" />

<p>右键新建，选择Spring Initializr (无法访问spring官网可以选择custom，<a target="_blank" rel="noopener" href="https://start.aliyun.com/">https://start.aliyun.com</a>)</p>
</li>
</ul>
<blockquote>
<p>更正：</p>
<p>这里我有mybatis-plus，我也不知道为啥，据说正常情况是没有的，重装系统之后又没有了</p>
<p>如果没有mybatis-plus选择，可直接在pom.xml导入如下依赖即可</p>
</blockquote>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>com.baomidou<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>mybatis-plus-boot-starter<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>3.5.1<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span><br></code></pre></td></tr></table></figure>


<ol>
<li><p>进入pom.xml，导入mybatis-plus自动生成的依赖  导入依赖后保存，sts保存后自动下载，idea需要点击右上角的 “M” 按钮，Load Maven Changes</p>
  <figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-comment">&lt;!--MyBatis-plus自动生成--&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>com.baomidou<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>mybatis-plus-generator<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>3.4.1<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span><br><span class="hljs-comment">&lt;!--velocity--&gt;</span><br><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>org.apache.velocity<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>velocity-engine-core<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>  <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>2.0<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span><br></code></pre></td></tr></table></figure></li>
<li><p>编写自动生成类，可自动生成简易版的（domain、mapper、mapper_xml、service、serviceimpl、controller）<br>如果想要生成比较完全的，可以去gitee上搜索“人人开源”，找到renren-generator，这个可以生成更完全，甚至可以生成前端的代码</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br><span class="line">49</span><br><span class="line">50</span><br><span class="line">51</span><br><span class="line">52</span><br><span class="line">53</span><br><span class="line">54</span><br><span class="line">55</span><br><span class="line">56</span><br><span class="line">57</span><br><span class="line">58</span><br><span class="line">59</span><br><span class="line">60</span><br><span class="line">61</span><br><span class="line">62</span><br><span class="line">63</span><br><span class="line">64</span><br><span class="line">65</span><br><span class="line">66</span><br><span class="line">67</span><br><span class="line">68</span><br><span class="line">69</span><br><span class="line">70</span><br><span class="line">71</span><br><span class="line">72</span><br><span class="line">73</span><br><span class="line">74</span><br><span class="line">75</span><br><span class="line">76</span><br><span class="line">77</span><br><span class="line">78</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-keyword">import</span> com.baomidou.mybatisplus.annotation.DbType;<br><span class="hljs-keyword">import</span> com.baomidou.mybatisplus.annotation.IdType;<br><span class="hljs-keyword">import</span> com.baomidou.mybatisplus.generator.AutoGenerator;<br><span class="hljs-keyword">import</span> com.baomidou.mybatisplus.generator.config.DataSourceConfig;<br><span class="hljs-keyword">import</span> com.baomidou.mybatisplus.generator.config.GlobalConfig;<br><span class="hljs-keyword">import</span> com.baomidou.mybatisplus.generator.config.PackageConfig;<br><span class="hljs-keyword">import</span> com.baomidou.mybatisplus.generator.config.StrategyConfig;<br><span class="hljs-keyword">import</span> com.baomidou.mybatisplus.generator.config.rules.DateType;<br><span class="hljs-keyword">import</span> com.baomidou.mybatisplus.generator.config.rules.NamingStrategy;<br><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">MyBatisPlusGenerator</span> &#123;<br>    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> <span class="hljs-keyword">void</span> <span class="hljs-title function_">main</span><span class="hljs-params">(String[] args)</span> &#123;<br>        <span class="hljs-comment">//1. 全局配置</span><br>        <span class="hljs-type">GlobalConfig</span> <span class="hljs-variable">config</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">GlobalConfig</span>();<br>        <span class="hljs-comment">// 是否支持AR模式</span><br>        config.setActiveRecord(<span class="hljs-literal">true</span>)<br>                <span class="hljs-comment">// 生成路径，最好使用绝对路径，window路径是不一样的</span><br>                <span class="hljs-comment">//TODO  TODO  TODO  TODO</span><br>                .setOutputDir(<span class="hljs-string">&quot;D:\demo\src\main\java&quot;</span>)<br>                <span class="hljs-comment">// 文件覆盖</span><br>                .setFileOverride(<span class="hljs-literal">true</span>)<br>                <span class="hljs-comment">// 主键策略</span><br>                .setIdType(IdType.AUTO)<br>                .setDateType(DateType.ONLY_DATE)<br>                <span class="hljs-comment">// 设置生成的service接口的名字的首字母是否为I，默认Service是以I开头的</span><br>                .setServiceName(<span class="hljs-string">&quot;%sService&quot;</span>)<br>                <span class="hljs-comment">//实体类结尾名称</span><br>                .setEntityName(<span class="hljs-string">&quot;%s&quot;</span>)<br>                <span class="hljs-comment">//生成基本的resultMap</span><br>                .setBaseResultMap(<span class="hljs-literal">true</span>)<br>                <span class="hljs-comment">//不使用AR模式</span><br>                .setActiveRecord(<span class="hljs-literal">false</span>)<br>                <span class="hljs-comment">//生成基本的SQL片段</span><br>                .setBaseColumnList(<span class="hljs-literal">true</span>);<br>        <span class="hljs-comment">//2. 数据源配置</span><br>        <span class="hljs-type">DataSourceConfig</span> <span class="hljs-variable">dsConfig</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">DataSourceConfig</span>();<br>        <span class="hljs-comment">// 设置数据库类型</span><br>        dsConfig.setDbType(DbType.MYSQL)<br>                .setDriverName(<span class="hljs-string">&quot;com.mysql.cj.jdbc.Driver&quot;</span>)<br>                <span class="hljs-comment">//TODO  TODO  TODO  TODO</span><br>                .setUrl(<span class="hljs-string">&quot;jdbc:mysql://127.0.0.1:3306/demo?useSSL=false&quot;</span>)<br>                .setUsername(<span class="hljs-string">&quot;root&quot;</span>)<br>                .setPassword(<span class="hljs-string">&quot;123456&quot;</span>);<br>        <span class="hljs-comment">//3. 策略配置globalConfiguration中</span><br>        <span class="hljs-type">StrategyConfig</span> <span class="hljs-variable">stConfig</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">StrategyConfig</span>();<br>        <span class="hljs-comment">//全局大写命名</span><br>        stConfig.setCapitalMode(<span class="hljs-literal">true</span>)<br>                <span class="hljs-comment">// 数据库表映射到实体的命名策略(驼峰命名)</span><br>                .setNaming(NamingStrategy.underline_to_camel)<br>                <span class="hljs-comment">//使用lombok</span><br>                .setEntityLombokModel(<span class="hljs-literal">true</span>)<br>                <span class="hljs-comment">//使用restcontroller注解</span><br>                .setRestControllerStyle(<span class="hljs-literal">true</span>)<br>                <span class="hljs-comment">// 生成的表, 支持多表一起生成，以数组形式填写</span><br>                <span class="hljs-comment">//TODO  TODO  TODO  TODO 两个方式，直接写，或者使用命令行输入</span><br>                .setInclude(<span class="hljs-string">&quot;u&quot;</span>);<br><span class="hljs-comment">//                .setInclude(&quot;product&quot;,&quot;product_task&quot;,&quot;banner&quot;);</span><br>        <span class="hljs-comment">//4. 包名策略配置</span><br>        <span class="hljs-type">PackageConfig</span> <span class="hljs-variable">pkConfig</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">PackageConfig</span>();<br>        <span class="hljs-comment">//TODO  TODO  TODO  TODO 包名策略配置</span><br>        pkConfig.setParent(<span class="hljs-string">&quot;com.example.demo&quot;</span>)<br>                .setMapper(<span class="hljs-string">&quot;mapper&quot;</span>)<br>                .setService(<span class="hljs-string">&quot;service&quot;</span>)<br>                .setServiceImpl(<span class="hljs-string">&quot;service.impl&quot;</span>)<br>                .setController(<span class="hljs-string">&quot;controller&quot;</span>)<br>                .setEntity(<span class="hljs-string">&quot;domain&quot;</span>)<br>                .setXml(<span class="hljs-string">&quot;mapper&quot;</span>);<br>        <span class="hljs-comment">//5. 整合配置</span><br>        <span class="hljs-type">AutoGenerator</span> <span class="hljs-variable">ag</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">AutoGenerator</span>();<br>        ag.setGlobalConfig(config)<br>                .setDataSource(dsConfig)<br>                .setStrategy(stConfig)<br>                .setPackageInfo(pkConfig);<br>        <span class="hljs-comment">//6. 执行操作</span><br>        ag.execute();<br>        System.out.println(<span class="hljs-string">&quot;======= 相关代码生成完毕  ========&quot;</span>);<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>
<p>有几个地方根据自己的需求改（标有 &#x2F;&#x2F;TODO  TODO 的地方）</p>
<ol>
<li>生成文件的路径</li>
<li>数据库连接的配置</li>
<li>生成哪几个表</li>
<li>包名策略配置</li>
</ol>
<p>运行main方法，自动生成（<strong>需要注意</strong>，生成之后注销掉方法，不然等你编写完springboot代码点击运行的时候，可能运行的还是自动生成的代码，导致你刚写完的代码被覆盖）</p>
<ol start="5">
<li>sts 运行完后需要右键刷新一下项目</li>
<li>在src&#x2F;main&#x2F;resources下新建mapper文件夹，将生成的mapper.xml移动到mapper文件夹下</li>
<li>如果不用lombok插件，则需要去掉实体类的注解，自己生成get、set方法 和 有参、无参的构造方法</li>
</ol>
<p><strong>注意@Data注解，不使用lombok插件的都需要自己生成get、set方法，下面使用@Data注解的位置我不再强调了</strong></p>
</li>
<li><p>配置application.properties</p>
<figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br></pre></td><td class="code"><pre><code class="hljs properties"><span class="hljs-comment"># 应用名称</span><br><span class="hljs-attr">spring.application.name</span>=<span class="hljs-string">demo</span><br><span class="hljs-comment"></span><br><span class="hljs-comment"># 应用服务 WEB 访问端口</span><br><span class="hljs-attr">server.port</span>=<span class="hljs-string">8080</span><br><span class="hljs-comment"></span><br><span class="hljs-comment"># 数据库驱动：</span><br><span class="hljs-attr">spring.datasource.driver-class-name</span>=<span class="hljs-string">com.mysql.cj.jdbc.Driver</span><br><span class="hljs-comment"># 数据源名称</span><br><span class="hljs-attr">spring.datasource.name</span>=<span class="hljs-string">defaultDataSource</span><br><span class="hljs-comment"># 数据库连接地址(demo是我们需要连接的数据库)</span><br><span class="hljs-attr">spring.datasource.url</span>=<span class="hljs-string">jdbc:mysql://localhost:3306/demo?serverTimezone=UTC</span><br><span class="hljs-comment"># 数据库用户名&amp;密码：</span><br><span class="hljs-attr">spring.datasource.username</span>=<span class="hljs-string">root</span><br><span class="hljs-attr">spring.datasource.password</span>=<span class="hljs-string">123456</span><br></code></pre></td></tr></table></figure>

<p>这里我的数据库连接地址这样就可以了，如果你们有问题，需要配置mysql的时区 或者 写完整 </p>
<figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs properties"><span class="hljs-comment"># 完整写法(demo是我们需要连接的数据库)</span><br><span class="hljs-attr">spring.datasource.url</span>=<span class="hljs-string">jdbc:mysql://localhost:3306/demo?useUnicode=true&amp;characterEncoding=utf8&amp;autoReconnect=true&amp;serverTimezone=Asia/Shanghai</span><br></code></pre></td></tr></table></figure>
</li>
<li><p>在启动类上加上注解（DemoApplication.java）</p>
<figure class="highlight properties"><table><tr><td class="gutter"><pre><span class="line">1</span><br></pre></td><td class="code"><pre><code class="hljs properties"><span class="hljs-attr">@MapperScan(&quot;com.example.demo.mapper&quot;)</span><br></code></pre></td></tr></table></figure>
</li>
<li><p>接下来编写一个简单的登录业务</p>
<ol>
<li><p>mapper继承了BaseMapper，有基本的增删改查方法，所以不用管</p>
</li>
<li><p>在service里编写</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-comment">// 登录</span><br><span class="hljs-keyword">public</span> Object <span class="hljs-title function_">login</span><span class="hljs-params">(U u)</span>;<br></code></pre></td></tr></table></figure>
</li>
<li><p>serviceimpl里实现该方法                 这里有个问题要说一下。</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-comment">// 如果你不准备改service层 以及 serviceimpl 的继承关系</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">interface</span> <span class="hljs-title class_">UService</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">IService</span>&lt;U&gt;&#123;<br>&#125;<br><br><span class="hljs-meta">@Service</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">UServiceImpl</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">ServiceImpl</span>&lt;UMapper, U&gt; <span class="hljs-keyword">implements</span> <span class="hljs-title class_">UService</span> &#123;<br>&#125;<br><span class="hljs-comment">// extends IService&lt;U&gt; 和 extends ServiceImpl&lt;UMapper, U&gt; 这两处</span><br><br><span class="hljs-comment">// 那么其实你在 UServiceImpl里不用再自动注入umapper了，如下</span><br><span class="hljs-meta">@Autowired</span><br><span class="hljs-keyword">private</span> UMapper umapper;<br><br><span class="hljs-comment">// 在UServiceImpl内，按住ctrl点击ServiceImpl，进入他的源码，你会发现里面有一个baseMapper</span><br><span class="hljs-comment">// 源码内：</span><br><span class="hljs-meta">@Autowired</span><br><span class="hljs-keyword">protected</span> M baseMapper;<br><span class="hljs-comment">// 仔细看看源码你就会发现baseMapper其实就是你的mapper层，所以不用再写mapper层的自动注入了，直接用baseMapper代替</span><br><br><span class="hljs-comment">// ------------------</span><br><br><span class="hljs-comment">// 还有一种说法，在service 和 serviceimpl里去掉他的继承关系，就是最原始的serviceimpl 实现 service即可</span><br><span class="hljs-comment">// 使用自动注入mapper的方式在serviceimpl内编写代码</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">interface</span> <span class="hljs-title class_">UService</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">IService</span>&lt;U&gt;&#123;<br>&#125;<br><br><span class="hljs-meta">@Service</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">UServiceImpl</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">ServiceImpl</span>&lt;UMapper, U&gt; <span class="hljs-keyword">implements</span> <span class="hljs-title class_">UService</span> &#123;<br>    <span class="hljs-meta">@Autowired</span><br>    <span class="hljs-keyword">private</span> UMapper umapper;<br>&#125;<br><span class="hljs-comment">// 因为继承IService 和 ServiceImpl实际上增加了耦合性，我们都知道，优秀的代码==高内聚、低耦合</span><br><br><span class="hljs-comment">// 以上两种写法请自行斟酌  这里我就用第一种了</span><br></code></pre></td></tr></table></figure>
</li>
<li><p>这里推介一个好用的工具包  hutool，导入依赖</p>
<figure class="highlight xml"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br></pre></td><td class="code"><pre><code class="hljs xml"><span class="hljs-tag">&lt;<span class="hljs-name">dependency</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">groupId</span>&gt;</span>cn.hutool<span class="hljs-tag">&lt;/<span class="hljs-name">groupId</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">artifactId</span>&gt;</span>hutool-all<span class="hljs-tag">&lt;/<span class="hljs-name">artifactId</span>&gt;</span><br>    <span class="hljs-tag">&lt;<span class="hljs-name">version</span>&gt;</span>5.8.10<span class="hljs-tag">&lt;/<span class="hljs-name">version</span>&gt;</span><br><span class="hljs-tag">&lt;/<span class="hljs-name">dependency</span>&gt;</span><br></code></pre></td></tr></table></figure>
</li>
<li><p>新建一个com.example.demo.util文件夹，新建R类</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br><span class="line">34</span><br><span class="line">35</span><br><span class="line">36</span><br><span class="line">37</span><br><span class="line">38</span><br><span class="line">39</span><br><span class="line">40</span><br><span class="line">41</span><br><span class="line">42</span><br><span class="line">43</span><br><span class="line">44</span><br><span class="line">45</span><br><span class="line">46</span><br><span class="line">47</span><br><span class="line">48</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-meta">@Data</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">R</span> &#123;<br><br>    <span class="hljs-keyword">private</span> <span class="hljs-type">int</span> code;<br><br>    <span class="hljs-keyword">private</span> String message;<br><br>    <span class="hljs-keyword">private</span> String type;<br><br>    <span class="hljs-keyword">private</span> Boolean success;<br><br>    <span class="hljs-keyword">private</span> Object data;<br><br>    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> R <span class="hljs-title function_">success</span><span class="hljs-params">(String message)</span> &#123;<br>        <span class="hljs-type">R</span> <span class="hljs-variable">r</span> <span class="hljs-operator">=</span> <span class="hljs-keyword">new</span> <span class="hljs-title class_">R</span>();<br>        r.setCode(<span class="hljs-number">200</span>);<br>        r.setMessage(message);<br>        r.setSuccess(<span class="hljs-literal">true</span>);<br>        r.setType(<span class="hljs-string">&quot;success&quot;</span>);<br>        r.setData(<span class="hljs-literal">null</span>);<br>        <span class="hljs-keyword">return</span> r;<br>    &#125;<br><br>    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> R <span class="hljs-title function_">success</span><span class="hljs-params">(String message, Object data)</span> &#123;<br>        <span class="hljs-type">R</span> <span class="hljs-variable">r</span> <span class="hljs-operator">=</span> success(message);<br>        r.setData(data);<br>        <span class="hljs-keyword">return</span> r;<br>    &#125;<br><br>    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> R <span class="hljs-title function_">warning</span><span class="hljs-params">(String message)</span> &#123;<br>        <span class="hljs-type">R</span> <span class="hljs-variable">r</span> <span class="hljs-operator">=</span> error(message);<br>        r.setType(<span class="hljs-string">&quot;warning&quot;</span>);<br>        <span class="hljs-keyword">return</span> r;<br>    &#125;<br><br>    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> R <span class="hljs-title function_">error</span><span class="hljs-params">(String message)</span> &#123;<br>        <span class="hljs-type">R</span> <span class="hljs-variable">r</span> <span class="hljs-operator">=</span> success(message);<br>        r.setSuccess(<span class="hljs-literal">false</span>);<br>        r.setType(<span class="hljs-string">&quot;error&quot;</span>);<br>        <span class="hljs-keyword">return</span> r;<br>    &#125;<br><br>    <span class="hljs-keyword">public</span> <span class="hljs-keyword">static</span> R <span class="hljs-title function_">fatal</span><span class="hljs-params">(String message)</span> &#123;<br>        <span class="hljs-type">R</span> <span class="hljs-variable">r</span> <span class="hljs-operator">=</span> error(message);<br>        r.setCode(<span class="hljs-number">500</span>);<br>        <span class="hljs-keyword">return</span> r;<br>    &#125;<br>&#125;<br></code></pre></td></tr></table></figure>
</li>
<li><p>编写serviceimpl</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br><span class="line">12</span><br><span class="line">13</span><br><span class="line">14</span><br><span class="line">15</span><br><span class="line">16</span><br><span class="line">17</span><br><span class="line">18</span><br><span class="line">19</span><br><span class="line">20</span><br><span class="line">21</span><br><span class="line">22</span><br><span class="line">23</span><br><span class="line">24</span><br><span class="line">25</span><br><span class="line">26</span><br><span class="line">27</span><br><span class="line">28</span><br><span class="line">29</span><br><span class="line">30</span><br><span class="line">31</span><br><span class="line">32</span><br><span class="line">33</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-meta">@Service</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">UServiceImpl</span> <span class="hljs-keyword">extends</span> <span class="hljs-title class_">ServiceImpl</span>&lt;UMapper, U&gt; <span class="hljs-keyword">implements</span> <span class="hljs-title class_">UService</span> &#123;<br><br>	<span class="hljs-meta">@Override</span><br>	<span class="hljs-keyword">public</span> Object <span class="hljs-title function_">login</span><span class="hljs-params">(U u)</span> &#123;<br>		<span class="hljs-comment">// TODO Auto-generated method stub</span><br>		<span class="hljs-comment">// 登录的情况</span><br>		<span class="hljs-comment">// 1.账号密码为空</span><br>		<span class="hljs-comment">// 2.账号未注册</span><br>		<span class="hljs-comment">// 3.密码错误</span><br>         <span class="hljs-comment">// 4.登陆成功</span><br>		<span class="hljs-keyword">if</span>(StrUtil.isEmptyIfStr(u)) &#123;<br>			<span class="hljs-keyword">return</span> R.error(<span class="hljs-string">&quot;账号密码为空&quot;</span>);<br>		&#125;<br>		QueryWrapper&lt;U&gt; userQuery=<span class="hljs-keyword">new</span> <span class="hljs-title class_">QueryWrapper</span>&lt;&gt;();<br>         <span class="hljs-comment">// 查找数据库，当数据库中name的值等于u.getName()的时候</span><br>		userQuery.eq(<span class="hljs-string">&quot;name&quot;</span>, u.getName());<br>         <span class="hljs-comment">// 从数据库中查找到的user（可能为空，即未注册）</span><br>		U user=baseMapper.selectOne(userQuery);<br>		<span class="hljs-keyword">if</span>(user==<span class="hljs-literal">null</span>) &#123;<br>			<span class="hljs-comment">// 用户未注册</span><br>			<span class="hljs-keyword">return</span> R.error(<span class="hljs-string">&quot;用户未注册&quot;</span>);<br>		&#125;<span class="hljs-keyword">else</span> &#123;<br>			<span class="hljs-comment">// 登录 成功 or 失败</span><br>			<span class="hljs-keyword">if</span>(user.getPassword().equals(u.getPassword())) &#123;<br>				<span class="hljs-keyword">return</span> R.success(<span class="hljs-string">&quot;登陆成功&quot;</span>);<br>			&#125;<span class="hljs-keyword">else</span> &#123;<br>				<span class="hljs-keyword">return</span> R.error(<span class="hljs-string">&quot;密码错误&quot;</span>);<br>			&#125;<br>		&#125;<br>	&#125;<br><br>&#125;<br></code></pre></td></tr></table></figure>
</li>
<li><p>编写controller</p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><span class="line">1</span><br><span class="line">2</span><br><span class="line">3</span><br><span class="line">4</span><br><span class="line">5</span><br><span class="line">6</span><br><span class="line">7</span><br><span class="line">8</span><br><span class="line">9</span><br><span class="line">10</span><br><span class="line">11</span><br></pre></td><td class="code"><pre><code class="hljs java"><span class="hljs-meta">@RestController</span><br><span class="hljs-meta">@RequestMapping(&quot;/user&quot;)</span><br><span class="hljs-keyword">public</span> <span class="hljs-keyword">class</span> <span class="hljs-title class_">UController</span> &#123;<br>	<span class="hljs-meta">@Autowired</span><br>	<span class="hljs-keyword">private</span> UService uservice;<br>	<br>	<span class="hljs-meta">@PostMapping(&quot;/login&quot;)</span><br>	<span class="hljs-keyword">public</span> Object <span class="hljs-title function_">checkLogin</span><span class="hljs-params">(<span class="hljs-meta">@RequestBody</span> U u)</span> &#123;<br>		<span class="hljs-keyword">return</span> uservice.login(u);<br>	&#125;<br>&#125;<br></code></pre></td></tr></table></figure>
</li>
<li><p>运行启动类（DemoApplication.java）</p>
</li>
</ol>
</li>
<li><p>目录结构</p>
   <img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931906.png" srcset="/img/loading.gif" lazyload alt="目录结构" style="zoom:67%;" />

   <img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931512.png" srcset="/img/loading.gif" lazyload alt="目录结构" style="zoom:67%;" />
</li>
<li><p>打开postman进行测试，没有的可以去<a target="_blank" rel="noopener" href="https://www.postman.com/downloads/?utm_source=postman-home">官网下载</a>，我这里也提供一份</p>
<p>  链接：<a target="_blank" rel="noopener" href="https://pan.baidu.com/s/1PfkZpMb_5zs9adP5TSRXRA?pwd=cc41">https://pan.baidu.com/s/1PfkZpMb_5zs9adP5TSRXRA?pwd=cc41</a><br>  提取码：cc41 </p>
  <img src="https://gitee.com/tongstyle/blog-img/raw/master/img/202301201931989.png" srcset="/img/loading.gif" lazyload alt="请求测试" style="zoom:67%;" />
</li>
<li><p>最后比较一下idea和sts。</p>
<p>   sts和eclipse差不多，上手难度低，需要配置的不多。相比之下idea上手难度高一些，需要配置的地方也多一些。</p>
<p>   但idea功能更多，比如安装一些插件，lombok、mybatis-plus的插件。建议用idea，编写代码真的比sts舒服很多。</p>
</li>
</ol>

                
              </div>
            
            <hr/>
            <div>
              <div class="post-metas my-3">
  
  
</div>


              
  

  <div class="license-box my-3">
    <div class="license-title">
      <div>新建SpringBoot项目</div>
      <div>http://example.com/2022/11/27/编程语言/Java/学习/框架/SpringBoot/新建springboot项目/</div>
    </div>
    <div class="license-meta">
      
        <div class="license-meta-item">
          <div>作者</div>
          <div>深海火锅店</div>
        </div>
      
      
        <div class="license-meta-item license-meta-date">
          <div>发布于</div>
          <div>2022年11月27日</div>
        </div>
      
      
      
        <div class="license-meta-item">
          <div>许可协议</div>
          <div>
            
              
              
                <a target="_blank" href="https://creativecommons.org/licenses/by/4.0/">
                  <span class="hint--top hint--rounded" aria-label="BY - 署名">
                    <i class="iconfont icon-by"></i>
                  </span>
                </a>
              
            
          </div>
        </div>
      
    </div>
    <div class="license-icon iconfont"></div>
  </div>



              
                <div class="post-prevnext my-3">
                  <article class="post-prev col-6">
                    
                    
                      <a href="/2022/11/28/%E7%BC%96%E7%A8%8B%E8%AF%AD%E8%A8%80/Java/%E9%A1%B9%E7%9B%AE/%E5%9F%BA%E4%BA%8ESpringBoot%E7%9A%84%E9%A1%B9%E7%9B%AE/%E9%9F%B3%E4%B9%90%E7%BD%91%E7%AB%99/1/" title="Vue + SpringBoot + MyBatis 音乐网站">
                        <i class="iconfont icon-arrowleft"></i>
                        <span class="hidden-mobile">Vue + SpringBoot + MyBatis 音乐网站</span>
                        <span class="visible-mobile">上一篇</span>
                      </a>
                    
                  </article>
                  <article class="post-next col-6">
                    
                    
                  </article>
                </div>
              
            </div>

            
          </article>
        </div>
      </div>
    </div>

    <div class="side-col d-none d-lg-block col-lg-2">
      
  <aside class="sidebar" style="margin-left: -1rem">
    <div id="toc">
  <p class="toc-header"><i class="iconfont icon-list"></i>&nbsp;目录</p>
  <div class="toc-body" id="toc-body"></div>
</div>



  </aside>


    </div>
  </div>
</div>





  



  



  



  



  







    

    
      <a id="scroll-top-button" aria-label="TOP" href="#" role="button">
        <i class="iconfont icon-arrowup" aria-hidden="true"></i>
      </a>
    

    
      <div class="modal fade" id="modalSearch" tabindex="-1" role="dialog" aria-labelledby="ModalLabel"
     aria-hidden="true">
  <div class="modal-dialog modal-dialog-scrollable modal-lg" role="document">
    <div class="modal-content">
      <div class="modal-header text-center">
        <h4 class="modal-title w-100 font-weight-bold">搜索</h4>
        <button type="button" id="local-search-close" class="close" data-dismiss="modal" aria-label="Close">
          <span aria-hidden="true">&times;</span>
        </button>
      </div>
      <div class="modal-body mx-3">
        <div class="md-form mb-5">
          <input type="text" id="local-search-input" class="form-control validate">
          <label data-error="x" data-success="v" for="local-search-input">关键词</label>
        </div>
        <div class="list-group" id="local-search-result"></div>
      </div>
    </div>
  </div>
</div>

    

    
  </main>

  <footer>
    <div class="footer-inner">
  
    <div class="footer-content">
       <a href="https://hexo.io" target="_blank" rel="nofollow noopener"><span>Hexo</span></a> <i class="iconfont icon-love"></i> <a href="https://github.com/fluid-dev/hexo-theme-fluid" target="_blank" rel="nofollow noopener"><span>Fluid</span></a> 
    </div>
  
  
    <div class="statistics">
  
  

  
    
      <span id="busuanzi_container_site_pv" style="display: none">
        总访问量 
        <span id="busuanzi_value_site_pv"></span>
         次
      </span>
    
    
      <span id="busuanzi_container_site_uv" style="display: none">
        总访客数 
        <span id="busuanzi_value_site_uv"></span>
         人
      </span>
    
    
  
</div>

  
  
  
</div>

  </footer>

  <!-- Scripts -->
  
  <script  src="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.js" ></script>
  <link  rel="stylesheet" href="https://lib.baomitu.com/nprogress/0.2.0/nprogress.min.css" />

  <script>
    NProgress.configure({"showSpinner":false,"trickleSpeed":100})
    NProgress.start()
    window.addEventListener('load', function() {
      NProgress.done();
    })
  </script>


<script  src="https://lib.baomitu.com/jquery/3.6.0/jquery.min.js" ></script>
<script  src="https://lib.baomitu.com/twitter-bootstrap/4.6.1/js/bootstrap.min.js" ></script>
<script  src="/js/events.js" ></script>
<script  src="/js/plugins.js" ></script>


  <script  src="https://lib.baomitu.com/typed.js/2.0.12/typed.min.js" ></script>
  <script>
    (function (window, document) {
      var typing = Fluid.plugins.typing;
      var subtitle = document.getElementById('subtitle');
      if (!subtitle || !typing) {
        return;
      }
      var text = subtitle.getAttribute('data-typed-text');
      
        typing(text);
      
    })(window, document);
  </script>




  
    <script  src="/js/img-lazyload.js" ></script>
  




  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/tocbot/4.18.2/tocbot.min.js', function() {
    var toc = jQuery('#toc');
    if (toc.length === 0 || !window.tocbot) { return; }
    var boardCtn = jQuery('#board-ctn');
    var boardTop = boardCtn.offset().top;

    window.tocbot.init(Object.assign({
      tocSelector     : '#toc-body',
      contentSelector : '.markdown-body',
      linkClass       : 'tocbot-link',
      activeLinkClass : 'tocbot-active-link',
      listClass       : 'tocbot-list',
      isCollapsedClass: 'tocbot-is-collapsed',
      collapsibleClass: 'tocbot-is-collapsible',
      scrollSmooth    : true,
      includeTitleTags: true,
      headingsOffset  : -boardTop,
    }, CONFIG.toc));
    if (toc.find('.toc-list-item').length > 0) {
      toc.css('visibility', 'visible');
    }

    Fluid.events.registerRefreshCallback(function() {
      if ('tocbot' in window) {
        tocbot.refresh();
        var toc = jQuery('#toc');
        if (toc.length === 0 || !tocbot) {
          return;
        }
        if (toc.find('.toc-list-item').length > 0) {
          toc.css('visibility', 'visible');
        }
      }
    });
  });
</script>


  <script src=https://lib.baomitu.com/clipboard.js/2.0.11/clipboard.min.js></script>

  <script>Fluid.plugins.codeWidget();</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/anchor-js/4.3.1/anchor.min.js', function() {
    window.anchors.options = {
      placement: CONFIG.anchorjs.placement,
      visible  : CONFIG.anchorjs.visible
    };
    if (CONFIG.anchorjs.icon) {
      window.anchors.options.icon = CONFIG.anchorjs.icon;
    }
    var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
    var res = [];
    for (var item of el) {
      res.push('.markdown-body > ' + item.trim());
    }
    if (CONFIG.anchorjs.placement === 'left') {
      window.anchors.options.class = 'anchorjs-link-left';
    }
    window.anchors.add(res.join(', '));

    Fluid.events.registerRefreshCallback(function() {
      if ('anchors' in window) {
        anchors.removeAll();
        var el = (CONFIG.anchorjs.element || 'h1,h2,h3,h4,h5,h6').split(',');
        var res = [];
        for (var item of el) {
          res.push('.markdown-body > ' + item.trim());
        }
        if (CONFIG.anchorjs.placement === 'left') {
          anchors.options.class = 'anchorjs-link-left';
        }
        anchors.add(res.join(', '));
      }
    });
  });
</script>


  
<script>
  Fluid.utils.createScript('https://lib.baomitu.com/fancybox/3.5.7/jquery.fancybox.min.js', function() {
    Fluid.plugins.fancyBox();
  });
</script>


  <script>Fluid.plugins.imageCaption();</script>

  <script  src="/js/local-search.js" ></script>

  <script defer src="https://busuanzi.ibruce.info/busuanzi/2.3/busuanzi.pure.mini.js" ></script>




  
<script src="//cdn.jsdelivr.net/gh/EmoryHuang/BlogBeautify@1.1/DynamicRibbon.min.js"></script>



<!-- 主题的启动项，将它保持在最底部 -->
<!-- the boot of the theme, keep it at the bottom -->
<script  src="/js/boot.js" ></script>


  

  <noscript>
    <div class="noscript-warning">博客在允许 JavaScript 运行的环境下浏览效果更佳</div>
  </noscript>
</body>
</html>
